<template>
  <div
    class="cardContainers"
    :style="{
      paddingBottom: tempData.paddingBottom + 'px',
      paddingLeft: tempData.paddingTwice + 'px',
      paddingRight: tempData.paddingTwice + 'px',
      paddingTop: tempData.paddingTop + 'px',
      boxSizing: 'border-box',
    }"
  >
    <div
      class="content"
      :style="
        tempData.showType == 1
          ? {
              borderTopLeftRadius: tempData.radiusNumTop + 'px',
              borderTopRightRadius: tempData.radiusNumTop + 'px',
              borderBottomLeftRadius: tempData.radiusNumBottom + 'px',
              borderBottomRightRadius: tempData.radiusNumBottom + 'px',
              backgroundColor: tempData.boxBg,
            }
          : {
              borderTopLeftRadius: tempData.radiusNumTop + 'px',
              borderTopRightRadius: tempData.radiusNumTop + 'px',
              borderBottomLeftRadius: tempData.radiusNumBottom + 'px',
              borderBottomRightRadius: tempData.radiusNumBottom + 'px',
              backgroundImage: 'url(' + tempData.bgImage + ')',
              backgroundSize: '100% 100%',
            }
      "
    >
      <div
        class="contentItem"
        v-for="(item, index) in tempData.tagList"
        :key="index"
        v-show="item.status"
      >
        <p class="title">{{ item.text }}</p>
        <p class="texts" :style="{ color: tempData.textColor }">{{ item.name }}</p>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { ref, watch } from 'vue'

  const props = defineProps({
    // 选中的当前组件参数
    compObj: {
      type: Object,
      default: () => {
        return {}
      },
    },
  })
  console.log(props)
  const tempData: any = ref({})
  watch(
    () => props.compObj,
    (newVal, oldVal) => {
      tempData.value = JSON.parse(JSON.stringify(newVal))
    },
    { immediate: true, deep: true }
  )
</script>

<style scoped lang="less">
  .cardContainers {
    width: 100%;
  }
  .content {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    // flex-wrap: wrap;
    flex-shrink: 0;
    background-color: #fff;
    padding: 14px 20px;
    box-sizing: border-box;
    scrollbar-width: none;
    overflow-x: scroll;
    .contentItem {
      width: 20.1%;
      flex-shrink: 0;
      display: flex;
      justify-content: center;
      align-content: center;
      flex-wrap: wrap;
      .title {
        width: 48px;
        font-size: 13px;
        line-height: 14px;
        color: #303133;
        text-align: left;
        margin-bottom: 3px;
      }
      .texts {
        width: 48px;
        font-size: 12px;
        color: #909399;
        text-align: center;
      }
    }
  }
</style>
